package com.grpc.controller;

import com.grpc.service.RemoteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import talkischeap.HelloRequest;

/**
 * create by yongli on 2022-04-14 15:17
 */

@RestController
@RequestMapping("/remote")
public class GrpcRemoteController {

    @Autowired
    RemoteService remoteService;

    @GetMapping("/hello")
    public String hello() {

        HelloRequest helloRequest = HelloRequest.newBuilder().setName("liyong").build();
        // HelloReply是不可以序列化的
        return remoteService.sayHello(helloRequest).getMessage();
    }

    @GetMapping("/health")
    public String health() {

        return "health";
    }

}
